package com.itheima.sc.web.pms;

import com.itheima.sc.pojo.pms.SkuStock;
import com.itheima.sc.result.Result;
import com.itheima.sc.service.pms.SkuStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("sku")
public class SkuStockController {
    @Autowired
    private SkuStockService skuStockService;

    //批量更新sku库存信息
    @PostMapping("update/{pid}")
    public Result updateByPid(@PathVariable Integer pid,
                              @RequestBody List<SkuStock> skuStockList){
        skuStockService.updateByPid(pid,skuStockList);
        return Result.success(null);
    }

    //根据商品ID及sku编码模糊搜索sku库存
    @GetMapping("{pid}")
    public Result getByPid_skuCode(@PathVariable Integer pid,@RequestParam(required = false) String keyword){
        List<SkuStock> list = skuStockService.getByPid_skuCode(pid,keyword);
        return Result.success(list);
    }








}
